package com.jmx.tomcat.servlet.api;

import com.jmx.tomcat.http.HttpRequest;
import com.jmx.tomcat.http.HttpResponse;

/**
 * @author: jmx
 * @date: 2023-08-11 19:27
 * @version: 1.0
 */
public abstract class GenericServlet implements Servlet{
    @Override
    public void init() {

    }

    @Override
    public void service(HttpRequest request, HttpResponse response) {
        if("GET".equalsIgnoreCase(request.getMethod())){
            doGet(request,response);
        }
        if("POST".equalsIgnoreCase(request.getMethod())){
            doPost(request,response);
        }
    }

    @Override
    public void destroy() {

    }
    public abstract void doGet(HttpRequest request, HttpResponse response);
    public abstract void doPost(HttpRequest request, HttpResponse response);
}
